#define _CRT_SECURE_NO_WARNINGS
#include "Stack.h"

bool isValid(char* s) {
    ST st;
    StackInit(&st);
    while (*s)
    {
        if (*s == '{' || *s == '(' || *s == '[')
        {
            StackPush(&st, *s);
        }
        else
        {
            char ch = StackTop(&st);
            StackPop(&st);
            if (*s == '}' && ch != '{')
                return false;
            if (*s == ']' && ch != '[')
                return false;
            if (*s == ')' && ch != '(')
                return false;
        }
        s++;
    }
    if (!StackEmpty(&st))
        return false;
    return true;
}

int main()
{
    char s[10];
    gets(s);
    isValid(s);
	return 0;
}